<div id="topBox" class="myAddresses">
	<h1 class="title"><?php echo $this->translate('myAddresses')?></h1>
	<p class="info"><?php echo $this->translate('placesWhereYouReceiveYourOrder')?></p>
		
    <?php 
    echo $this->MyFlashMessenger();

	if (isset($this->clienteDirecciones)){
	
		$n=1;
		
		foreach ($this->clienteDirecciones as $direccion){
			
			$url = $this->url(
						array(	'controller'=>'cliente', 
								'action'=>'eliminar-direccion', 
								'idDireccionCliente'=>$direccion->idDireccionCliente), 'default');
			
			echo "<div class='address".($n==1?' firstAddress':null)."'>
					<a class='delete' href='$url'>".$this->translate('delete')."</a>
					<a class='showMap' href='{$direccion->latitud}_{$direccion->longitud}'>".$this->translate('showMap')."</a>
					<p class='name'>{$direccion->nombre}</p>
					<p class='street'>{$direccion->calle} {$direccion->numero} {$direccion->depto}</p>
					<p class='city'>".(empty($direccion->barrio) ? null : $direccion->barrio . ', ')."{$direccion->getCiudad()->nombre}</p>
				</div>";
			
			$n++;
		}	
		
	} 	
	?>
</div>

<div id="bottomBox" class="myAddresses">
	<h2 class="title"><?php echo $this->translate('addAddress')?></h2>
	<p class="info"><?php echo $this->translate('completeData')?></p>
	<?php 
	if (isset($this->direccionesEncontradas)){
		
		echo $this->getHelper('Message')->warning( $this->translate('manyAddressesMatch') );
		echo '<div class="addressesFound"><ul>';
		
		foreach ($this->direccionesEncontradas as $direccion){
			
			$href = $this->url(array(
				'controller'=>'cliente', 
				'action'=>'link-address', 
				'idDireccion'=>$direccion->idDireccion,
				'depto'=>$this->depto,
				'nombre'=>$this->nombre,
			),'default');
			
			echo "<li><a href='$href'>$direccion</a></li>";
		}		
		
		echo '</ul></div>';
	} else {
		echo $this->getHelper('Message')->warning( $this->translate('keepsYourDataUpdated') );
	}
	
	?>
	<form action="<?php echo $this->escape($this->form->getAction()) ?>"
      id="<?= $this->escape($this->form->getName()) ?>"
      method="<?= $this->escape($this->form->getMethod()) ?>">

		<div class="zend_form">
			<?= $this->form->nombre ?>
		    <?= $this->form->calle ?>
		    <?= $this->form->numero ?>
		    <?= $this->form->depto ?>
		    <?= $this->form->ciudad ?>
			<div class="submit-group">
				<a class="button redButton buttonIcon"><span><span class="icon"></span><?php echo $this->translate('save')?></span></a>
			</div>
		</div>
	</form>
</div>


<?php

if ( !isset($this->whiteLabelType )){
    $this->renderToPlaceholder('side/box-info-help.phtml','side');
} else {
    $this->renderToPlaceholder('negocio/side-white-label.phtml','side');
}
$this->renderToPlaceholder('side/tip-mydata.phtml','side');

$this->jQuery()->onLoadCaptureStart();?>

$(".myAddresses .delete").click(function(){

	var $link = $(this);

	Boxy.confirm("<?php echo $this->translate('confirmDeleteAddress')?>", function() { location.href = $link.attr("href")});
    return false;
});	

bindFormAddAddress();
bindMyAddressMap();
<?php	
$this->jQuery()->onLoadCaptureEnd();

$this->headTitle()->append( $this->translate('meta-title-my-addresses') );
$this->headMeta()->appendName('keywords', $this->translate('meta-keywords-my-addresses') );
$this->headMeta()->appendName('description', $this->translate('meta-description-my-addresses'));